#pragma once
#include <QThread>
#include <QMutex>
#include <QWaitCondition>
#include <QImage>
#include <QTcpSocket>

class ReceiveThread : public QThread {
    Q_OBJECT
public:
    ReceiveThread(QObject* par = nullptr) : QThread(par) {}
    void readMessage(const QByteArray& msg);

signals:
    void recvPing(const time_t& rtt);
    void recvImg(const QImage& img);
    void recvAudio(const QByteArray& audioData);
    void recvText(const QString& text);
    void recvCreated(const quint16 roomId);
    void recvJoined(const quint16 roomId, const QList<quint16>& partnerList);
    void recvNewPartner(const quint16 userId);
    void recvLeavedPartner(const quint16 userId);
    void recvDbStatus(const QByteArray& status, const quint16& userId, const QByteArray& username, const quint16& userType);
    void recvHistoryMsg(const QByteArray& data);
    void recvExpertsMsg(const QByteArray& data);
    void recvInvitationMsg(const QByteArray& data);

private:
    QMutex queue_lock;
    QWaitCondition queue_waitCond;
    void run() override;
    QMutex m_lock;
};
